

import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View, Image, 
  Animated,
  Easing,
} from 'react-native';
import {createStore, applyMiddleware,combineReducers} from 'redux';
import thunk from 'redux-thunk';
import { Provider, connect } from 'react-redux';
import reducer from './src/reducers';
import {
  createReduxContainer,
  createReactNavigationReduxMiddleware,
  createNavigationReducer,
} from 'react-navigation-redux-helpers';

import {createAppContainer } from 'react-navigation';

import TabNavigator from './Nav';
//const store = createStore(reducer, applyMiddleware(thunk))
//export default createAppContainer(TabNavigator);

const AppNavigator = createAppContainer(TabNavigator);
const navReducer = createNavigationReducer(AppNavigator);
const appReducer = combineReducers({
  nav: navReducer, // required, handle actions from react-navigation
  reducers: reducer, // optional, this is your reducers
});
const middleware = createReactNavigationReduxMiddleware(
  state => state.nav,
  'root',
);
//const App = reduxifyNavigator(AppNavigator, 'root');
const App = createReduxContainer(AppNavigator, 'root');
const mapStateToProps = state => ({
  state: state.nav,
});
 
const AppWithNavigationState = connect(mapStateToProps)(App);
 
const store = createStore(appReducer, applyMiddleware(middleware));
 
class Root extends Component {
  render() {
    return (
      <Provider store={store}>
        <AppWithNavigationState />
      </Provider>
    );
  }
}
 
export default () => <Root />;


//export default createAppContainer(TabNavigator);


